import express, { Express, Request, Response } from 'express';

const app:Express = express();

app.get('/login', (req:Request,res:Response)=> {
  res.header("Access-Control-Allow-Origin", '*');//允许跨域
  if (req.query.user == 'admin1' && req.query.password == '123') {
    res.json({
      code:0,
      route: [
        {
          path: "/demo1",
          name: "demo1",
          component:'demo1.vue'
        },{
          path: "/demo2",
          name: "demo2",
          component:'demo2.vue'
        },{
          path: "/demo3",
          name: "demo3",
          component:'demo3.vue'
        },
      ]
    })
  } else if (req.query.user == 'admin2' && req.query.password == '123') {
    res.json({
      code:0,
      route: [
        {
          path: "/demo1",
          name: "demo1",
          component:'demo1.vue'
        },{
          path: "/demo2",
          name: "demo2",
          component:'demo2.vue'
        },
      ]
    })
  } else {
    res.json({
      code: 4000,
      message:'账号密码错误'
    })
  }
})

app.listen(3333, () => {
  console.log('your server listening on http://localhost:3333')
})